/**
 * @param {number[]} nums
 * @param {number} k
 * @return {number}
 */
var partitionArray = function(nums, k) {
  if(nums.length == 1)
    return 1;
  nums = nums.sort((a, b) => a - b);
  let count = 1, temp = nums[0];
  for(let i = 0; i < nums.length; i++) {
    if(nums[i] - temp > k) {
      temp = nums[i];
      count++;
    }
  }
  return count;
};
let nums = [3,6,1,2,5], k = 2;
console.log(partitionArray(nums, k));
nums = [1,2,3], k = 1;
console.log(partitionArray(nums, k));
nums = [2,2,4,5], k = 0;
console.log(partitionArray(nums, k));
nums = [16,8,17,0,3,17,8,20], k = 10;
console.log(partitionArray(nums, k));
nums = [0,12,8,14,9,13,17,15], k = 4;
console.log(partitionArray(nums, k));
